package org.lds.message.center.client.util;

import org.lds.message.center.common.enums.ErrorEnum;
import org.lds.message.center.common.model.ResultDTO;
import org.lds.message.center.service.grpc.GrpcResultDTO;

import java.util.Objects;

public class ResultDTOUtil {
    public static ResultDTO toResultDTO(GrpcResultDTO grpcResultDTO) {
        if (Objects.isNull(grpcResultDTO)) return ResultDTO.fail(ErrorEnum.SYSTEM_ERROR);
        return ResultDTO.result(grpcResultDTO.getCode(), grpcResultDTO.getMessage(), grpcResultDTO.getSuccess(), null);
    }

}
